package my.mypool.core;

import org.apache.commons.pool.PoolableObjectFactory;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2010-9-20
 * Time: 11:24:42
 * To change this template use File | Settings | File Templates.
 */
public abstract class PoolableParent implements PoolableObjectFactory {
    private Object createParam=null;

    public void setCreateParam(Object createParam) {
        this.createParam = createParam;
    }

    public final Object makeObject() throws Exception {
        PoolableParent obj=this.getClass().newInstance();
        obj.init(createParam);
        return obj;
    }

    public void destroyObject(Object o) throws Exception {
        ((PoolableParent)o).destroy();
    }

    public boolean validateObject(Object o) {
        return ((PoolableParent)o).validate();
    }

    public void activateObject(Object o) throws Exception {
        ((PoolableParent)o).activate();
    }

    public  void passivateObject(Object o) throws Exception{
        ((PoolableParent)o).passivate();
    }



     public abstract void destroy() throws Exception;
     public abstract boolean validate();
     public abstract void activate() throws Exception;
     public abstract void passivate() throws Exception;
     public abstract void init(Object param) throws Exception;
}
